package com.hschinese.pronunciation.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hschinese.pronunciation.R;

/**
 * Created by wo on 2015/10/30.
 */
public class Header extends RelativeLayout {
    private View mView = null;
    private TextView mTitle = null;
    private ImageView mBackImg = null;
    private ImageView iv_header_center = null;

    public Header(Context context) {
        super(context);
    }

    public Header(Context context, AttributeSet attrs) {
        super(context, attrs);
        mView = LayoutInflater.from(context).inflate(R.layout.header, null);
        mTitle = (TextView)mView.findViewById(R.id.id_header_title);
        mBackImg = (ImageView)mView.findViewById(R.id.id_header_back);
        iv_header_center = (ImageView)mView.findViewById(R.id.iv_header_center);
        this.addView(mView);
    }

    public void setTitle(String t) {
        if (t != null) {
            mTitle.setText(t);
        }
    }
    public void setTitleDraw(int t) {
        iv_header_center.setImageResource(t);
    }

    public void setLeftImgVisibility(int visibility) {
        mBackImg.setVisibility(visibility);
    }

    public void setLeftClickListener(OnClickListener listener) {
        mBackImg.setOnClickListener(listener);
    }
}
